import axios from "axios";
import { showToast } from "vant";

// 创建 axios 的实例

const request = axios.create({
  baseURL: "https://m.maizuo.com/gateway",
});

// 请求拦截
request.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

// 响应拦截
request.interceptors.response.use(
  (response) => {
    return response.data;
  },
  (error) => {
    showToast({
      message: error || "网络异常，请稍后重试",
      position: "top",
    });
    return Promise.reject(error);
  }
);

export default request;
